package com.chensf.studydemo.constraint

import android.os.Bundle
import android.transition.TransitionManager
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import com.chensf.studydemo.R
import kotlinx.android.synthetic.main.keyframe_one.*

class ConstraintLayoutDemo : AppCompatActivity(){
    private lateinit var constraintLayout: ConstraintLayout

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.keyframe_one)
        constraintLayout = findViewById(R.id.constraint_layout)
        button1.setOnClickListener {
            animateToKeyframeTwo()
        }
    }

    private fun animateToKeyframeTwo(){
        val constraintSet = ConstraintSet()
        constraintSet.load(this,R.layout.keyframe_two)
        TransitionManager.beginDelayedTransition(constraintLayout)
        constraintSet.applyTo(constraintLayout)
    }
}